<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script type="text/javascript" src="http://api.map.baidu.com/api??v=1.5&ak=Bkr2mjnARtGsksAIs2FcHU55"></script>
</head>
<div id="mapdiv" style="position: absolute; top:0px; right:0px;">
    <div style="width:500px;">   
        <li>
	        <input id="text_" type="hidden" value="" style="width: 220px;"/>
	        <input type="hidden" id="mapstatu" value=""/>
        <li>
        <div id="container" 
            style="position: absolute; 
                width: 500px; 
                height: 374px; 
                float: right;
    			margin-top: 572px
                border: 1px solid gray;
                overflow:hidden;
               ">
        </div>
    </div>
</div>
<script type="text/javascript">
    var map = new BMap.Map("container");
	map.centerAndZoom("杭州", 13);
	var point = new BMap.Point(120.120044,30.339848);
	map.centerAndZoom(point,12);
	map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
    var localSearch = new BMap.LocalSearch(map);
    localSearch.enableAutoViewport(); //允许自动调节窗体大小
	var iscreatr=false; 
	map.addEventListener("click", function(e){  
		if(iscreatr==true)return;  
		iscreatr=true;  
		map.clearOverlays();//清空原来的标注
		 var point = new BMap.Point(e.point.lng ,e.point.lat);//默认  
		 var marker = new BMap.Marker(point);    
		 map.addOverlay(marker);    
		 marker.enableDragging();    //可拖拽  
	}); 
	function searchByStationName() {
	    map.clearOverlays();//清空原来的标注
	    var keyword = document.getElementById("text_").value;
	    localSearch.setSearchCompleteCallback(function (searchResult) {
	        var poi = searchResult.getPoi(0);
	        //document.getElementById("result_").value = poi.point.lng + "," + poi.point.lat;
	        map.centerAndZoom(poi.point, 13);
	    	map.clearOverlays();//清空原来的标注
	        var marker = new BMap.Marker(new BMap.Point(poi.point.lng, poi.point.lat));  // 创建标注，为要查询的地方对应的经纬度
	        map.addOverlay(marker);
	        var content = document.getElementById("text_").value + "<br/><br/>经度：" + poi.point.lng + "<br/>纬度：" + poi.point.lat;	
	        var infoWindow = new BMap.InfoWindow("<p style='font-size:14px;'>" + content + "</p>");
			map.addOverlay(marker);    
			marker.enableDragging();    //可拖拽  
	    });
	    localSearch.search(keyword);
	} 
</script>
</html>